import random

from selenium.webdriver.common.by import By

from base import BaseAction


class DocGdPageHome(BaseAction):
    next_ele = By.XPATH, '//span[text()="下一步"]'
    fac_ele = By.XPATH, '//input[@placeholder="请搜索并选择加工厂"]'
    quick_order_ele = By.XPATH, '//*[@class="yg-form"]/div[1]/div/div/div[1]'
    requirement_notes_ele = By.XPATH, '//*[@id="ZJaddWin"]//textarea'  # 需求备注
    upload_model_ele = By.XPATH, '//*[@id="ZJaddWin"]//div[1]/div[1]/div[2]/button[2]/span[text()="直接上传"]'
    upload_upper_ele = By.XPATH, '//*[@id="messageareaupload"]/div[1]/div[1]/div[1]/div[2]/div[@class="vueupbtn vueupbtn1"]'
    upload_lower_ele = By.XPATH, '//*[@id="messageareaupload"]/div[1]/div[1]/div[2]/div[2]/div[@class="vueupbtn vueupbtn2"]'
    upload_success_ele = By.XPATH, '//*[text()="100%"]'
    ok_ele = By.XPATH, '//div[2]/button/span[text()="确定"]'
    recent_visit_ele = By.XPATH, '//span[text()="最近访问"]'
    submit_ele = By.XPATH, '//span[text()="提交"]'
    submit_success_ele = By.XPATH, '//*[text()="归档完成！"]'

    # 医生查看方案
    search1_js_ele = By.XPATH, '//*/form/div[2]/div/div/div'  # 点击筛选框
    search2_js_ele = By.XPATH, '//*[@class="yg-search-bar"]//div[2]//*[text()="方案待审核"]'  # 筛选病例
    search_js_button_ele = By.XPATH, '//*[text()="查询"]'  #
    see_ele = By.XPATH, '//*[@id="gdpatiente-new"]/tbody/tr[1]/td[10]/i[2]'  # 查看方案
    success_ele = By.XPATH, '//span[text()="0%"]'  # 判断进度条有没有到0
    view_scenarios_ele = By.XPATH, '//*[@id="playAraeFooter"]/button[3]'  # 播放方案按钮
    permission1_ele = By.XPATH, '//*[@id="app"]/div[2]/div/button[1]'  # 批准方案
    permission2_ele = By.XPATH, '//*[@id="yg_msgbox_dom"]/div/div[3]/input[1]'  # 确认批准
    close_ele = By.XPATH, '//*[@id="app"]/div[4]/div[2]/div/span[7]/i'  # 关闭方案

    # 点击下一步
    def get_next_ele(self):
        return self.get_element(self.next_ele)

    def get_fac_ele(self):
        return self.get_element(self.fac_ele)

    def get_use_fac_ele(self, fac_name):
        use_fac_ele = By.XPATH, f'//*[@id="ZJaddWin"]//div[3]/div[2]/span[text()="{fac_name}"][1]'
        return self.get_element(use_fac_ele)

    def get_quick_order_ele(self):
        return self.get_element(self.quick_order_ele)

    def get_requirement_notes_ele(self):
        return self.get_element(self.requirement_notes_ele)

    def get_upload_model_ele(self):
        return self.get_element(self.upload_model_ele)

    def get_upload_upper_ele(self):
        return self.get_element(self.upload_upper_ele)

    def get_upload_lower_ele(self):
        return self.get_element(self.upload_lower_ele)

    def get_upload_success_ele(self):
        return self.get_element(self.upload_success_ele)

    def get_ok_ele(self):
        return self.get_element(self.ok_ele)

    def get_recent_visit_ele(self):
        return self.get_element(self.recent_visit_ele)

    def get_technician_ele(self, js_name):
        technician_ele = By.XPATH, f'//span[text()="{js_name}"]'
        return self.get_element(technician_ele)

    def get_submit_ele(self):
        return self.get_element(self.submit_ele)

    def get_submit_success_ele(self):
        return self.get_element(self.submit_success_ele)

    # 医生查看方案
    def get_search1_js_ele(self):
        return self.get_element(self.search1_js_ele)

    def get_search2_js_ele(self):
        return self.get_element(self.search2_js_ele)

    def get_search_js_button_ele(self):
        return self.get_element(self.search_js_button_ele)

    def get_see_ele(self):
        return self.get_element(self.see_ele)

    def get_view_scenarios_ele(self):
        return self.get_element(self.view_scenarios_ele)

    def get_permission1_ele(self):
        return self.get_element(self.permission1_ele)

    def get_permission2_ele(self):
        return self.get_element(self.permission2_ele)

    def get_close_ele(self):
        return self.get_element(self.close_ele)

    def get_success_ele(self):
        return self.get_element(self.success_ele)
